GBML manual / Input

action_pressed

True this frame if the named action is pressed (the frame it went down) (see btn_pressed for the raw-button equivalent). The action is one of the names in your project’s Project Settings, written as a plain word: `action_pressed(jump)`.

Syntax

action_pressed(a) -> bool

Arguments

NameType
aaction

Returns

bool

Description

True only on the frame the named action goes down - the same check as btn_pressed, but for a name your project chose (fire, jump) instead of a fixed button. It is the one to use for "do this once per press", like jumping or opening a menu.

An action can have more than one button, and each button is watched on its own. Pressing a second button of the same action while the first is still down counts as a new press.

An action with no button in Project Settings is never pressed, and asking about it is not an error. See Project settings.

Example

if (action_pressed(jump)) {
    vsp = -4;
}

The frame jump goes down, the instance is thrown upward. Holding it does not throw it again.

On the GBA

The action is whatever buttons Project Settings gave it, and the engine keeps that mapping - so action_rebind() changes what it means for the rest of the run, and no code that asks about the action needs to change. An action with several buttons counts as pressed when ANY of them is; an action with no buttons is never true.

See also: action_heldaction_releasedaction_rebindbtn_pressedProject settings